<?php 


//包含网站配置文件
include '../public/webconfig.php';
//包含数据库配置文件
include '../public/dbconfig.php';
//包含函数库文件
include '../public/func.inc.php';
//调用函数
$link = conn();
//var_dump($link);
//exit;
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>帖子列表页</title>
		<style type="text/css">
			/*公共样式*/
			html,body,div,span,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,address,big,cite,code,del,em,font,img,ins,small,strong,var,b,u,i,center,tr,td,th,dl,dt,dd,ol,ul,li,fieldset,form,label,legend{margin:0;padding:0}
			ul{
				/*列表样式：无*/
				list-style-type:none;
			}
				/*a交钱无下划线*/
				a:link{
					color:black;
					text-decoration:none;}
			
			.header{
				width:1030px;
				height:22px;
				line-height:22px;
				/*border:1px solid red;*/
				margin:0 auto;
				background:url(./resource/images/background.png) repeat-x;}
				
			.one{
				width:745px;
				height:65px;
				/*border:1px solid red;*/
				margin:0 auto;
				}
				.tubiao{
				float:left;}
				
			div.touxiang{
				float:right;}
				
			div table tr{
				font-size:10px;
				line-height:32px;}
				
			.two{
				width:745px;
				height:28px;
				line-height:25px;
				/*border:1px solid red;*/
				margin:0 auto;
				background:url(./resource/images/nv.png) repeat-x;}
				
			div.luntan{
				background:blue;
				color:white;
				font-size:16px;
				padding:1px;
				float:left;}
				
			div.daohang{
				float:right;
				background-color:white;}
				
			div.sousuo{
				width:745px;
				height:34px;
				line-height:34px;
				margin:0 auto;
				background:#E8EFF5;}
				
			div.xiaofangzi{
				width:745px;
				height:3opx;
				line-height:30px;
				margin:0 auto;}
				
				
			div.xiaofangzi table tr th:nth-child(1){
				width:40px;
				height:30px;
				line-height:30px;
				aline:center;}
		
			div.xiaofangzi table tr th:nth-child(2){
				width:40px;
				height:30px;
				line-height:30px;
				aline:center;}
				
			div.xiaofangzi table tr th:nth-child(3){
				width:40px;
				height:30px;
				line-height:30px;
				aline:center;}
				
			.xiaofangzi .xfz1{
				float:left;
				}
				
			.xiaofangzi .xfz2{
				float:left;
				}
				
			.xiaofangzi .xfz3{
				margin-left:10px;
				}
				
			.bankuaiguanli{
				width:745px;
				heighe:30px;
				line-height:30px;
				margin:0 auto;
				border:1px solid #D1D1D1;
				}
				
			.morenbankuai{
				
				float:left;
				font-size:20px;
				padding-left:20px;}
				
			.guanlimianban{
				float:right;
				font-size:20px;
				padding-right:20px;
				}
				
			.jrz{
				float:right;
				}
			
			.fatiefanhui{
				width:745px;
				height:40px;
				margin:0 auto;}
				
			
				
			
				
				
			/*.fatiefanhui input{
				float:right;}*/
				
			/*发帖与发帖之间*/
			.neirong{
				width:745px;
				height:0px;
				border:1px solid #DDE3E7;
				margin:0 auto;}
				
			/*快速发帖*/
			.kuaisufatie{
				width:730px;
				height:40px;
				line-height:40px;
				maigin:0 auto;
				background:#DDE3E7;
				padding-left:20px;}
				
			.last{
				width:745px;
				height:200px;
				border:1px solid #DDE3E7;}
				
				
			/*页尾*/
			.yewei{
				width:745px;
				height:50px;
				border-top:1px solid #C1D4E2;
				margin-top:20px;
				padding:20px 0 40px 0;
				color:#C1D4E2;
				font-size:14px;}
		
		
		
		</style>
		
	
	
	
	</head>
	<body>
		<div class="header">
			<a href="">设为首页</a>
			<a href="">收藏本站</a>
		</div>
		<div class="one">
			<!--------------------网站logo----------------------->
				<div class="tubiao"><img src="./resource/images/s_<?php echo WZ_LOGO;?>" width="100" height="60"></div>
			<div class="touxiang">
				<table width="500" height="32"  cellspacing="0">
					<tr align="center">
						<td><a href=""><?php session_start(); echo $_SESSION['uname'];?>在线</a></td>
						<td>我的<select><option value="1">手机号登录</option><option value="2">邮箱登录</option></select></td>
						<td><a href="user.php">设置</a></td>
						<td><a href="">消息</a></td>
						<td><a href="">提醒</a><select><option></option></select></td>
						<td><a href="">模块管理</a></td>
						<td><a href="">管理中心</a></td>
						<td><a href="tuichu.php">退出</a></td>
						<td rowspan="2"><img src="../uploads/<?php session_start(); echo $_SESSION['pic'];?>" width="50" height="50"></td>
					
					</tr>
					<tr>
						<td colspan="6"></td>
						<td>积分:13<select><option><option></select></td>
						<td>用户组:管理员<select><option></option></select></td>
					</tr>
				
				</table>
			
			
			</div>
		
		
		
		</div>
		<div class="two">
			<div class="luntan">论坛</div>
			<div class="daohang">导航论坛<select><option></option></select></div>
		</div>
		<div class="sousuo">
				<span style="padding-left:20px;"><input type="text" name="title" placeholder="请搜索内容" style="width:300px"></span>
				<span><select><option value="帖子">帖子</select></span>
				<a href="" style="color:black;font-size:20px;">热搜</a>
				<a href="" style="color:blue;">活动</a>
				<a href="" style="color:blue;">交友</a>
				<a href="" style="color:blue;">discuz</a>
				
		</div>
		<div class="xiaofangzi">
			<a href="" class="xfz3"><img src="./resource/images/2016-10-29_162601.jpg">默认版块</a>
			<div class="xfz1"><img src="./resource/images/2016-10-29_162315.jpg"><a href="">论坛</a></div>
			<div class="xfz2"><img src="./resource/images/2016-10-29_162601.jpg"><a href="">Discuz!</a></div>

		
		</div>
		<div class="bankuaiguanli">
			<div class="guanlimianban"><img src="./resource/images/2016-12-05_113726.jpg">管理面板</div>
			<div class="jrz">
				<a href="">收藏本版<img src="./resource/images/2016-10-29_172516.jpg"></a>
				<a href="">订阅<img src="./resource/images/2016-10-29_172602.jpg"></a>
				<a href="">回收站</a>
			
			
			</div>
			<div class="morenbankuai">默认版块</div>
			<div>
				<a href="">今日:<img src="./resource/images/2016-10-29_172233.jpg"></a>
				<a href="">主题:<img src="./resource/images/2016-10-29_172325.jpg"></a>
				<a href="">排名:<img src="./resource/images/2016-10-29_172421.jpg"></a>
			</div>
		</div>	
			
		<div class="neirong">
		<table>
			<table width="745" height=""  cellspacing="0">
				<tr style="background-color:#DCE2E6">
					<td colspan="5">
						<a href="">全部主题<select><option></option></select></a>
						<a href="">最新</a>
						<a href="">热门</a>
						<a href="">热帖</a>
						<a href="">精华</a>
						<a href="">更多<select><option></option></select></a>
					</td>
					<th><a href="">作者</a></th>
					<th><a href="">回复查看</a></th>
					<th><a href="">最后发表</a></th>
				</tr>
				<?php
				//------------分页---------
				//当前页  如果点击链接传页数 就使用传的页数 否则就是第1页
				$page = isset($_GET['page']) ? $_GET['page'] : 1;
				
				//每页显示的条数
				$pageRow = 5;
				//n 当前页-1 * 每页显示条数
				$offset = ($page - 1) * $pageRow;
				//分页原理  n,m
				$limit = "limit {$offset},{$pageRow}";
				//接受a标签链接传值
				if(!empty($_GET['id'])){
					$cid = $_GET['id'];
					$_SESSION['id'] = $cid;
				}
				
				
				
				//------查询语句---------
				$sql = "select * from bbs_post where cid={$cid} {$limit}";
				
				//var_dump($sql);
				//exit;
				
				//---------执行语句----------
				$res = mysqli_query($link,$sql);
				//---------循环获取关联表中数据------------
				if($res){
				
				while($cinfo = mysqli_fetch_assoc($res)){
				//var_dump($cinfo);
				//exit;
				
				
				?>
				
				
				
				
				<tr>
					<td colspan="5">
						<img src="./resource/images/2016-10-29_191342.jpg"><a href="./ftnr.php?id=<?php echo $cinfo['id'];?>"><?php echo $cinfo['title'];?></a><img src="./resource/images/2016-10-29_191611.jpg"></td>
					<th>
						<ul>
							<li><a href=""><?php echo $_SESSION['uname'];?></a></li>
							<li><a href=""><?php echo date('Y-m-d',$cinfo['ptime']);?></a></li>
						</ul>
					</th>
					<th>
						<ul>
							<li><a href="./ftnr.php?id=<?php echo $cinfo['id'];?>"><?php echo $cinfo['count'];?></a></li>
							<li><a href="./ftnr.php?id=<?php echo $cinfo['id'];?>"><?php echo $cinfo['count'];?></a></li>
						</ul>
					</th>
					<th>
						<ul>
							<li><a href="./details.php"><?php echo $_SESSION['uid'];?></a></li>
							<li><a href="./details.php"><?php echo date('Y-m-d',$cinfo['ptime']);?></a></li>
						</ul>
					</th>
					
				
				</tr>
				<?php
				}
				
				}
				?>
				
				
			
			</table>
				<?php
			//---------总条数---------
			//总条数
			
			$csql = "select count(*) as c from bbs_post where cid={$cid}";
			//var_dump($csql);
			//exit;
			$cres = mysqli_query($link,$csql);
			
			$cinfo = mysqli_fetch_assoc($cres);
			//var_dump($cres);
			//exit;
			//var_dump($cinfo);
			//-------------总页数------------
			//求总页数  = ceil(总条数 / 每页显示的条数)  进一法取整
			//--------------下一页----------------------
			$countPage = ceil($cinfo['c'] / $pageRow);
			//计算下一页  当前页 + 1
			$nextPage = $page + 1;
			//越界判断  如果超过总页数 值就为总页数
			if($nextPage > $countPage){
			$nextPage = $countPage;
			}
			//-------------上一页--------
			//计算上一页 当前页 - 1
			$prevPage = $page - 1;
			//越界判断 如果小于1 就为1
			if($prevPage < 1){
			$prevPage = 1;
			}
	
			?>
	<tr>
    <td align="left" valign="top" class="fenye">共<?php echo $cinfo['c'];?>条数据 <?php echo $page;?>/<?php echo $countPage?> 页&nbsp;&nbsp;<a href="list.php?page=1&id=<?php echo $_SESSION['id'];?>" target="mainFrame" onFocus="this.blur()">首页</a>&nbsp;&nbsp;<a href="list.php?page=<?php echo $prevPage;?>&id=<?php echo $_SESSION['id'];?>" target="mainFrame" onFocus="this.blur()">上一页</a>&nbsp;&nbsp;<a href="list.php?page=<?php echo $nextPage;?>&id=<?php echo $_SESSION['id'];?>" target="mainFrame" onFocus="this.blur()">下一页</a>&nbsp;&nbsp;<a href="list.php?page=<?php echo $countPage;?>&id=<?php echo $_SESSION['id'];?>" target="mainFrame" onFocus="this.blur()">尾页</a></td>
  </tr>
  </table>
			<div class="fatiefanhui">
				
				<input type="image" src="./resource/images/pn_post.png">
				<div style="float:right;">
				<a href=""><img src="./resource/images/pn_reply.png"></a>
				</div>
				
			
			</div>
		
			<div class="kuaisufatie"><a href="">快速发帖</a></div>
			<form action="dofatie.php" method="post">
			<input type="hidden" name="id" value="<?php echo $_SESSION['id'];?>">
			<div class="last">
				<div>
					<input type="text" name="title">还可以输入80个字符
				</div>
				
			
			
			
			
			
			
				<div>
				<textarea name="content" style="width:500px; height:100px;resize:none;"></textarea>
		
				</div>
				<span>验证码<input type="text" name="yzm"><a>换一个</a></span><br></br>
				<input type="submit" value="发表帖子">
				<!--<div><a href=""style="background:blue; color:white;" >发表帖子</a></div>-->
			</div>
			</form>
			<div class="yewei">
				
				<div style="float:right">
					<ul>
						<li>Archive &nbsp;手机版 &nbsp;手机版&nbsp;Comsenzinc</li>
						<li>GMT+8,2015-7-24&nbsp;13:00,processed&nbsp;in&nbsp;1.243252(s),&nbsp;17quenes.</li>
					
					</ul>
				
				
				</div>
				<div>
					<ul>
						<li>Powered$nbsp;DISSOUZ!X3.2</li>
						<!-------------网站版权---------------->
						<li><?php echo WZ_BQ;?></li>
					
					</ul>
					
				
				</div>
			
			</div>
	
		
	
	
	
	
	
	</body>







</html>